PRIN 2022 (Settore LS2)
Start date: 28 September 2023
End date: 27 September 2025
by Filippo Biscarini
With this post, we begin a super-elementary tutorial on the use of the software package QGIS for the processing of geo-referenced image data: QGIS is a free and open-source framework for geographic information system (GIS) data.
A few introductory assumptions:
For the installation of QGIS and for technical details, you can have a look at the official documentation (here).
There are two basic types of image files that are processed in QGIS: 1) raster images (pixel based images), and 2) vectorial images. In this tutorial, in a first instance we will focus on raster images.
Let’s say that our objective is to extract interesting areas from the orthomosaic: in the case of the polyploidbreeding project these will be
the different field plots where different accessions are planted or treatments applied.
Geo-referenced orthomosaic image files are typically in the .tiff
format (tagged image file format),
accompanied by a .tfw
file of GIS coordinated (TFW).
For example, we can look at the image below, where we have three geo-referenced plots that need to be separated for further processing.
First, we suggest that you create a QGIS project: this will make it easier to handle input files, output folders and option setting. To create a project, once you opened QGIS, you will use the main menu (top bar):
Project
> New
Project
> Save
: choose a location (directory) and a name where to save the project; this will create a .qgz
fileProject
> Properties
and sett the Project home
folder; this will make it much easier to browse for input/output files and foldersNow that we have our QGIS project, we can import the orthomosaic image file (a single image of the whole agricultural field):
from the software menu bar: Layer
> Add Layer
> Add Raster Layer
, and select the input .tiff/.tif image file.
The second ingredient of geo-referenced image file analysis is the shape file: this is a file that indicates the boundaries of the areas of interest in the image file, i.e. the experimental plots in our example.
The shape file may be already available (from the preprocessing of drone-phenotyping images), or can be designed by the user. We take this second case, in this first post on QGIS and the processing of orthomosaic image files.
To make a new shape file in QGIS we can do the following:
Layer
> Create Layer
> New Shapefile Layer
:
Geometry type
: e.g. Polygon
if you need to draw an area (like in the case of field sub-plots)New field
: i) id (default); ii) name; iii) etc.Layer
> Toggle Editing
Polygon
icon on the top toolbarid
and name
of each subplotLayer
> Save Layer Edits
You may want to make sure that, besides having created the shapefile layer and saved it within your project, you save the sahpfile layer to an external shape file, for future use.
Now that we have the orthomosaic raster image file and the shape file, we can split the orthomosaic into the subplots of interest based on the shapes drawn in the shape file. To do so, and save separate files for each subplot, we first need to select the shape (area) to export:
Layers
panel (bottom-left), right-click on the shapefile layer, and select Open Attribute Table
;Attribute Table
, select the desired shape by clicking on it (it will be highlighted, e.g. in blue)Raster
> Extraction
> Clip Raster by Mask Layer
:
Selected feature only
option (this is important: it will clip only the selected shape from the Attribute Table)Run
Save as
Now we have three image files for the three subplots in the original orthomosaic image: job done!
All right, we learnt how to read the orthomosaic, make the shape file and use it to split the orthomosaic into the relevant subplots. Still, a couple of challenges are immediately obvious:
We’ll deal with these issues in our next post of this introductory tutorial to QGIS.
tags: qgis - images - informatics